Skip to content

feat: new position details on crvusd/lend #1097

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 87 commits into
base: main
Choose a base branch
from

Conversation

OnlyJousting
Copy link
Contributor

@OnlyJousting OnlyJousting commented Jun 25, 2025

This PR introduces new views market/position details for /create, /manage and /vault on the crvusd and lend market pages. They are available when BETA features are enabled.

Changes:

  • New position details component with emphasis on the health value
  • New market details component
  • New layout for market information. Moving from having it split up in two tabs into having them unified into one view
  • Moves a lot of related data fetching to react-queries

Copy link
Collaborator

@0xAlunara 0xAlunara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lots of comments and wrok that needs to be done, but shouldn't be too much of an issue as the new feature is behind a beta flag; can improve in new PRs.

Some of my comments also apply to other areas as well, given there's some code duplication going on wrt the loan and lend apps.

marginTop: Spacing.xl,
marginBottom: Spacing.xxl,
gap: Spacing.xl,
flexDirection: 'column',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stack is column in direction by default, prob not needed

gap: Spacing.xl,
flexDirection: 'column',
// 960px
'@media (min-width: 60rem)': {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[theme.breakpoints.down('desktop')]: {
  flexDirection: 'row'
},

or, in useBreakpoints.ts:

const isDesktopUp = (theme: Theme) => theme.breakpoints.down('desktop')
export const useIsDesktopDown = () => useMediaQuery(isDesktopDown)
<Stack direction={useIsDesktopDown() ? 'row' : 'column'}> </Stack>

960px should be close enough to desktop breakpoint.

Point is, hardcoding media stuff like this should be avoided, esp sizes.

gap: Spacing.xl,
flexDirection: 'column',
// 960px
'@media (min-width: 60rem)': {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as PageLoanCreate

gap: Spacing.xl,
flexDirection: 'column',
// 960px
'@media (min-width: 60rem)': {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as page loan create numero dos

const [selectedBand, setSelectedBand] = useState<'user' | 'market'>(page === 'create' ? 'market' : 'user')

const SelectorMenu =
page === 'create' ? null : (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

page && (<SelectorRow
Although I'm not sure, might show false lol


return (
<Box sx={{ display: 'flex', flexDirection: 'column', gap: LABEL_GAP }} paddingBottom="0.3125rem">
<Box sx={{ display: 'flex', position: 'relative', width: '100%', height: '1rem' }}>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<Stack direction="row">

export const HealthDetails = ({ health }: { health: Health }) => {
const theme = useTheme()
return (
<Box
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<Stack>, in multiple places here

label={t`Health`}
value={Number(health?.value)}
loading={health?.loading}
valueOptions={{ unit: 'percentage', decimals: 2, color: getHealthValueColor(health?.value ?? 0, theme) }}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you inline useTheme() here you can use arrow-body notation and reduce indenting by a level 🤓

{t`Health determines a position liquidation. It is not directly correlated to the price of the collateral. `}
</Typography>
<Typography variant="bodyXsRegular" sx={{ fontWeight: (t) => t.typography.fontWeightBold }}>
{t`Liquidations occur when health reaches 0.`}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Liquidations may occur 🤓

loading={borrowAPY?.value == null && borrowAPY?.loading}
valueOptions={{ unit: 'percentage' }}
notional={
borrowAPY?.thirtyDayAvgRate
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not just here, but in a lot of <Metric /> usages in this PR you use a ternary in notionals. I think you can get away using the && operator instead?

borrowAPY?.thirtyDayAvgRate && { value: borrowAPY.thirtyDayAvgRate, unit: { symbol: '% 30D Avg', position: 'suffix' }}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants